package com.infore.siteManagement.controller.equipment;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson.JSONObject;
import com.infore.siteManagement.entity.equipment.EquipmentModel;
import com.infore.siteManagement.select.dto.QueryParamDto;
import com.infore.siteManagement.service.equipment.IEquipModelService;
import com.infore.siteManagement.util.ResultEntity;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(value = "仪器模板管理接口", tags = { "仪器模板管理接口" })
@RestController
@RequestMapping("/equipModel")
public class EquipModelController {

	@Autowired
	private IEquipModelService iEquipModelService;

	@ApiOperation(value = "查询仪器模板通用接口")
	@ResponseBody
	@PostMapping(value = "/query")
	public ResultEntity query(@RequestBody(required = false) QueryParamDto queryParamDto) {
		return iEquipModelService.query(queryParamDto);
	}

	@ApiOperation(value = "删除仪器模板通用接口")
	@ApiImplicitParams(@ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true, dataType = "String"))
	@DeleteMapping(value = "/delete")
	public ResultEntity delete(String id) {
		return iEquipModelService.delete(id);
	}

	@ApiOperation(value = "编辑/新增仪器模板通用接口")
	@ResponseBody
	@PostMapping(value = "/edit")
	public ResultEntity edit(String jsons, MultipartFile[] imageFiles, MultipartFile[] accessoryFiles) {
		EquipmentModel equipmentModel = JSONObject.parseObject(jsons, EquipmentModel.class);
		return iEquipModelService.edit(equipmentModel, imageFiles, accessoryFiles);
	}
}
